package eteam.aps.common.component;

import eteam.aps.common.helper.Helper;
import eteam.aps.systeminterface.model.vo.Worksheets;


/**
 * 获取单号通用方法
 *
 *
 * @author WMT
 * @Date 2023/2/20 14:53
 */
public class GetOrderNumber {

    public static String getOrderNumber(Worksheets worksheets, String maxOrderNumber) {
        // 配置单号
        String prefix = null;
        int length = 0;
        if (worksheets != null){
            prefix = worksheets.getfPrefix();
            length = worksheets.getfStreamLength();
        }
        if (Helper.isEmpty(maxOrderNumber)) {
            String number = String.format("%0" + length + "d", 1);
            return prefix + number;
        } else {
            String streamLength = maxOrderNumber.substring(maxOrderNumber.length() - length);
            int count = Integer.parseInt(streamLength);
            count++;
            String suffix = String.format("%0" + length + "d", count);
            return prefix + suffix;
        }
    }
}
